package edu.guet.server.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DatetimeSwitch {
    public static LocalDateTime parseStringToLocalDateTime(String timeString) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime dateTime = LocalDateTime.parse(timeString, formatter);
        return dateTime;
    }

    public static String parseLocalDateTimeToString(LocalDateTime time) {
        // 定义日期时间格式化器
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // 将 LocalDateTime 格式化为字符串
        String formattedDateTime = time.format(formatter);
        return formattedDateTime;
    }
}
